@echo off
chcp 65001 > nul
color a
title 获取系统信息 --by Dazen %date% %time%
setlocal enabledelayedexpansion

if exist "C:\Users\%username%\Desktop\%computername%-%username%.txt" (
    del /q "C:\Users\%username%\Desktop\%computername%-%username%.txt" >nul 2>&1
)

echo 请稍候，信息正在读取中...

Rem 获取操作系统版本
for /f "delims=" %%a in ('wmic os get Caption^,OSArchitecture^,Version /value ^| findstr /i "="') do (
    echo 操作系统: %%a>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

echo 当前计算机名:%computername%>>C:\Users\%username%\Desktop\%computername%-%username%.txt
echo 当前用户名:%username%>>C:\Users\%username%\Desktop\%computername%-%username%.txt

Rem 获取IP地址
for /f "delims=" %%a in ('wmic nicconfig where "IPEnabled='TRUE'" get IPAddress /value ^| findstr /i "IPAddress="') do (
    set var=%%a
    for /f "tokens=2 delims==" %%b in ("!var!") do (
        echo IP地址:%%b>>C:\Users\%username%\Desktop\%computername%-%username%.txt
    )
)

Rem 获取MAC地址
for /f "tokens=2 delims==" %%a in ('wmic nicconfig where "IPEnabled='TRUE'" get MACAddress /value ^| findstr /i "MACAddress="') do (
    set "ma=%%a"
    goto :1
)
:1
echo MAC地址:%ma%>>C:\Users\%username%\Desktop\%computername%-%username%.txt

Rem 获取主板信息
for /f "skip=1 tokens=*" %%a in ('wmic baseboard get Manufacturer^,Product^,Version^,SerialNumber /value ^| findstr /i "="') do (
    echo 主板信息:%%a>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

Rem 获取CPU信息
for /f "skip=1 tokens=*" %%a in ('wmic cpu get Name^,MaxClockSpeed^,NumberOfCores /value ^| findstr /i "="') do (
    echo CPU信息:%%a>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

Rem 获取显示器分辨率
for /f "skip=1 tokens=*" %%a in ('wmic desktopmonitor get ScreenWidth^,ScreenHeight /value ^| findstr /i "="') do (
    echo 显示器分辨率:%%a>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

Rem 获取硬盘信息
for /f "skip=1 tokens=*" %%a in ('wmic diskdrive get Model^,InterfaceType^,Size /value ^| findstr /i "="') do (
    echo 硬盘信息:%%a>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

Rem 获取内存信息
for /f "skip=1 tokens=*" %%a in ('wmic memorychip get Capacity /value ^| findstr /i "="') do (
    set "var=%%a"
    set /a var=!var!/1024/1024
    echo 内存: !var!MB>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

Rem 获取显卡信息
for /f "skip=1 tokens=*" %%a in ('wmic path win32_videocontroller get Description /value ^| findstr /i "="') do (
    echo 显卡信息:%%a>>C:\Users\%username%\Desktop\%computername%-%username%.txt
)

cls
type C:\Users\%username%\Desktop\%computername%-%username%.txt
pause>nul
